package com.aps.apspda.activity;

import android.content.Intent;
import android.os.Handler;
import android.os.Message;
import android.os.Vibrator;
import android.support.v7.widget.DefaultItemAnimator;
import android.support.v7.widget.DividerItemDecoration;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.text.Editable;
import android.text.TextWatcher;
import android.view.Gravity;
import android.view.KeyEvent;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.animation.Animation;
import android.view.animation.RotateAnimation;
import android.widget.Button;
import android.widget.CompoundButton;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import android.widget.TextView;
import android.widget.Toast;
import android.widget.ToggleButton;

import com.aps.apspda.R;
import com.aps.apspda.adapter.EqpThingListAdapter;
import com.aps.apspda.adapter.InputDataListAdapter;
import com.aps.apspda.adapter.MessageListAdapter;
import com.aps.apspda.adapter.PopDownAreaListAdapter;
import com.aps.apspda.adapter.ThingListAdapter;
import com.aps.apspda.base.BaseActivity;
import com.aps.apspda.callback.DeleteCallback;
import com.aps.apspda.callback.DialogEntityCallBack;
import com.aps.apspda.callback.EntityCallBack;
import com.aps.apspda.dialog.DeleteFragmentDialog;
import com.aps.apspda.dialog.GeneralPop;
import com.aps.apspda.dialog.WarnFragmentDialog;
import com.aps.apspda.dialog.WarnPop;
import com.aps.apspda.entity.BaseEntity;
import com.aps.apspda.entity.EqpEntity;
import com.aps.apspda.entity.FinishLotEntity;
import com.aps.apspda.entity.InputDataEntity;
import com.aps.apspda.entity.InputDatasEntity;
import com.aps.apspda.entity.LotInfoEntity;
import com.aps.apspda.entity.MaterialInfoBean;
import com.aps.apspda.entity.MessageEntity;
import com.aps.apspda.entity.PicEntity;
import com.aps.apspda.myview.ClearEditText;
import com.aps.apspda.myview.TitleView;
import com.aps.apspda.utils.AntiShake;
import com.aps.apspda.utils.AppUtils;
import com.aps.apspda.utils.NetUtils;
import com.aps.apspda.utils.StaticMembers;
import com.aps.apspda.utils.StringUtils;
import com.aps.apspda.utils.ToastUtils;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.google.gson.Gson;
import com.google.gson.reflect.TypeToken;
import com.lzy.okgo.OkGo;
import com.lzy.okgo.model.Response;

import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Timer;
import java.util.TimerTask;

import butterknife.BindView;
import butterknife.OnClick;

import static com.aps.apspda.activity.StartFunctionActivity.requestClassNum;
import static com.aps.apspda.activity.StartFunctionActivity.showPicPop;

public class StartFunction_SingulationActivity extends BaseActivity {

    @BindView(R.id.topView)
    TitleView topView;
    @BindView(R.id.etLotItem)
    EditText etLotItem;
    @BindView(R.id.etNum)
    EditText etNum;
    @BindView(R.id.tvLogId)
    TextView tvLogId;
    //    @BindView(R.id.tvDevice)
//    TextView tvDevice;
//    @BindView(R.id.tvWafer)
//    TextView tvWafer;
    @BindView(R.id.tvEdgeRecipeId)
    TextView tvEdgeRecipeId;   //add by bunny
    @BindView(R.id.tvEdgeRecipeNo)
    TextView tvEdgeRecipeNo;   //add by bunny

    @BindView(R.id.tvRecipeName)
    TextView tvRecipeName;
    @BindView(R.id.tvRecipeNo)
    TextView tvRecipeNo;
    @BindView(R.id.rvThingList)
    RecyclerView rvThingList;
    @BindView(R.id.tvDeviceNo)
    TextView tvDeviceNo;
    @BindView(R.id.tvStatus)
    TextView tvStatus;
    @BindView(R.id.rvEqpList)
    RecyclerView rvEqpList;
    @BindView(R.id.ivRight)
    ImageView ivRight;
    @BindView(R.id.tvPic)
    TextView tvPic;
    @BindView(R.id.tvPicVersion)
    TextView tvPicVersion;
    @BindView(R.id.rlPic)
    RelativeLayout rlPic;
    @BindView(R.id.etRemark)
    EditText etRemark;
    @BindView(R.id.tvMore)
    TextView tvMore;
    @BindView(R.id.rvMessageList)
    RecyclerView rvMessageList;
    @BindView(R.id.ivDownArrow)
    ImageView ivDownArrow;
    @BindView(R.id.rlInfo)
    RelativeLayout rlInfo;
    @BindView(R.id.tvSubmitRemark)
    TextView tvSubmitRemark;
    @BindView(R.id.btnChange)
    Button btnChange;
    @BindView(R.id.btnStartKa)
    Button btnStartKa;
    @BindView(R.id.btnStartCut)
    Button btnStartCut;
    @BindView(R.id.tvBlock)
    TextView tvBlock;
    @BindView(R.id.tvPianNo)
    TextView tvPianNo;
    @BindView(R.id.tvPackage)
    TextView tvPackage;
    @BindView(R.id.llCard)
    LinearLayout llCard;
    @BindView(R.id.rvInputList)
    RecyclerView rvInputList;
    @BindView(R.id.ivDownArrow2)
    ImageView ivDownArrow2;
    @BindView(R.id.toggleButton)
    ToggleButton toggleButton;
    @BindView(R.id.llMain)
    LinearLayout llMain;
    @BindView(R.id.btnTest)
    Button btnTest;
    @BindView(R.id.tvChoose)
    TextView tvChoose;
    @BindView(R.id.btnBothChange)
    Button btnBothChange;
    @BindView(R.id.tvAlreadyDown)
    TextView tvAlreadyDown;
    @BindView(R.id.etClassNum)
    ClearEditText etClassNum;
    @BindView(R.id.tvSubmitInputClassNum)
    TextView tvSubmitInputClassNum;
    @BindView(R.id.etBladeExp)
    ClearEditText etBladeExp;
    @BindView(R.id.llBladeExp)
    LinearLayout llBladeExp;
    private List<MessageEntity> messageEntityList;
    private Timer timer;
    private ThingListAdapter thingListAdapter;
    private EqpThingListAdapter eqpThingListAdapter;
    private MessageListAdapter messageListAdapter;
    private InputDataListAdapter inputDataListAdapter;
    private String LotID = "";
    private String startMode = "A";
    private Animation animation, animationDismiss;
    private List<InputDatasEntity.InputObjects> inputList = new ArrayList<>();
    private InputDatasEntity.InputObjects currentInputObject = new InputDatasEntity.InputObjects();
    private List<InputDataEntity.InputObject> submitInputList = new ArrayList<>();
    private List<WarnPop> dialogList = new ArrayList<>();
    private GeneralPop generalPop;
    private List<MaterialInfoBean> materialInfoBeanList;
    private  String eqpType;
    private LotInfoEntity lotInfo;
    private String pic, picVersion;
    private Handler mHandler = new Handler();
    private Runnable runnable = new Runnable() {
        @Override
        public void run() {
            StartFunction_SingulationActivity.this.finish();
        }
    };
    Handler handler = new Handler() {
        @Override
        public void handleMessage(Message msg) {
            super.handleMessage(msg);
            // 将返回值回调到callBack的参数中
            switch (msg.what) {
                case 0:
                    requestData();
                    break;
            }
        }
    };

    private void dealMessage(List<MessageEntity> data) {
        boolean isOk = true;
        dialogList.clear();
        for (int i = 0; i < data.size(); i++) {
            if (data.get(i).getISALERT()) {
                WarnPop warnPop = new WarnPop(this, data.get(i).getMESSAGE(), data.get(i).getCOLOR());
                dialogList.add(warnPop);
                if (timer != null) {
                    timer.cancel();
                }
            }
            if (data.get(i).getISEQPSTATUS()) {
                tvStatus.setText(data.get(i).getEQPSTATUS());
            }
        }
        for (int j = 0; j < dialogList.size(); j++) {
            final WarnPop warnPop = dialogList.get(j);
            try {
                warnPop.showAtLocation(llMain, Gravity.CENTER, 0, 0);
            } catch (Exception e) {
                isOk = false;
                e.printStackTrace();
            }
            if (j == 0) {
                warnPop.setOnlickListener(new View.OnClickListener() {
                    @Override
                    public void onClick(View v) {
                        warnPop.dismiss();
                        startTimer();
                    }
                });
            } else {
                warnPop.setOnlickListener(new View.OnClickListener() {
                    @Override
                    public void onClick(View v) {
                        warnPop.dismiss();
                    }
                });
            }
        }
        if (isOk) {
            Vibrator vibrator = (Vibrator) this.getSystemService(this.VIBRATOR_SERVICE);
            vibrator.vibrate(1000 * dialogList.size());
        }
    }
    //2019-12-25 增加 Start
    private void showdailog(String message) {
        final WarnFragmentDialog dialog = new WarnFragmentDialog();
        dialog.setData(message);
        dialog.setListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                dialog.dismiss();
                mHandler.postDelayed(runnable, 100);
            }
        });
        dialog.show(getSupportFragmentManager(), "check_fail_tips");
    }
    //2019-12-25 增加 End
    private void startTimer() {
        timer = new Timer();
        timer.schedule(new TimerTask() {
            @Override
            public void run() {
                requestMessageData();
            }
        }, 0, 2000);
    }

    private void requestMessageData() {
        EntityCallBack<BaseEntity<List<MessageEntity>>> callBack = new EntityCallBack<BaseEntity<List<MessageEntity>>>
                (new TypeToken<BaseEntity<List<MessageEntity>>>() {
                }.getType()) {

            @Override
            public void onSuccess
                    (final Response<BaseEntity<List<MessageEntity>>> response) {
                if (response.body().isSuccess(StartFunction_SingulationActivity.this)) {
                    messageEntityList.clear();
                    messageEntityList.addAll(response.body().getData());
                    messageListAdapter.notifyDataSetChanged();
                    dealMessage(response.body().getData());
                } else {
                    loadFail(response.body().getMessage());
                }
            }

            @Override
            public void onError
                    (Response<BaseEntity<List<MessageEntity>>> response) {
                super.onError(response);
                AppUtils.saveErrorMessages(response.getException(), "SHOWMSG2PDA");
                if (isActive) {
                    ToastUtils.showFreeToast("获取实时消息失败",
                            StartFunction_SingulationActivity.this, false, Toast.LENGTH_SHORT);
                }
            }
        };

        Map<String, String> map = new HashMap<>();
        map.put("EQPID", getEqpID());
        map.put("number", "5");
        NetUtils.requestNet(this, "/SHOWMSG2PDA", map, callBack);
    }

    private void requestData() {
        EntityCallBack<BaseEntity<EqpEntity>> callBack = new DialogEntityCallBack<BaseEntity<EqpEntity>>
                (new TypeToken<BaseEntity<EqpEntity>>() {
                }.getType(), getSupportFragmentManager(), this) {

            @Override
            public void onSuccess
                    (final Response<BaseEntity<EqpEntity>> response) {
                if (response.body().isSuccess(StartFunction_SingulationActivity.this)) {
                    startTimer();
                    refreshPop();
                    EqpEntity eqpEntity = response.body().getData();
                    eqpType=eqpEntity.getEQPTYPE();
                    String modetype = eqpEntity.getEQPModeType();
                    if (modetype.equals("Y")) {
                        StaticMembers.isOffLine = true;
                        llBladeExp.setVisibility(View.VISIBLE);
                        topView.setTitle("批次开始(" + StaticMembers.CUR_USER.getUSERNAME() + ")离线模式");
                    } else {
                        StaticMembers.isOffLine = false;
                        llBladeExp.setVisibility(View.GONE);
                        topView.setTitle("批次开始(" + StaticMembers.CUR_USER.getUSERNAME() + ")正常模式");
                    }
                    inputList = eqpEntity.getINPUTDATALIST().getINPUTDATA();
                    if (eqpEntity.getMATERIALINFO().getMATERIALINFO().size() == 0) {
                        loadFail("该设备没有设置BOM,请联系相关人员");
                    }
                    tvDeviceNo.setText(eqpEntity.getEQPID());
                    tvStatus.setText(eqpEntity.getCONTROLSTATUS());
                    switch (eqpEntity.getISTESTSTATE()) {
                        case "start":
                            btnTest.setVisibility(View.VISIBLE);
                            btnTest.setText("结束打测试片");
                            btnTest.setOnClickListener(new View.OnClickListener() {
                                @Override
                                public void onClick(View v) {
                                    if (AntiShake.check(v.getId())) {    //判断是否多次点击
                                        ToastUtils.showFreeToast("请勿重复点击",
                                                StartFunction_SingulationActivity.this, false, Toast.LENGTH_SHORT);
                                        return;
                                    }
                                    requestTest("EndTest");
                                }
                            });
                            break;
                        case "end":
                            btnTest.setVisibility(View.VISIBLE);
                            btnTest.setText("打测试片");
                            btnTest.setOnClickListener(new View.OnClickListener() {
                                @Override
                                public void onClick(View v) {
                                    if (AntiShake.check(v.getId())) {    //判断是否多次点击
                                        ToastUtils.showFreeToast("请勿重复点击",
                                                StartFunction_SingulationActivity.this, false, Toast.LENGTH_SHORT);
                                        return;
                                    }
                                    final DeleteFragmentDialog deleteFragmentDialog = new DeleteFragmentDialog();
                                    deleteFragmentDialog.setData("请保存当前Recipe", new View.OnClickListener() {
                                        @Override
                                        public void onClick(View v) {
                                            deleteFragmentDialog.dismiss();
                                            requestTest("StartTest");
                                        }
                                    });
                                    deleteFragmentDialog.show(getSupportFragmentManager(), "delete_dialog");
                                }
                            });
                            break;
                        case "no":
                        case "":
                            btnTest.setVisibility(View.GONE);
                            break;
                    }
                    if (eqpEntity.getMATERIALINFO().getMATERIALINFO().size() == 2 &&
                            eqpEntity.getMATERIALINFO().getMATERIALINFO().get(0).getType().toLowerCase().contains("hubblade")
                            && eqpEntity.getMATERIALINFO().getMATERIALINFO().get(1).getType().toLowerCase().contains("hubblade")) {
                        btnBothChange.setVisibility(View.VISIBLE);
                        materialInfoBeanList = eqpEntity.getMATERIALINFO().getMATERIALINFO();
                    } else {
                        btnBothChange.setVisibility(View.GONE);
                    }
                    eqpThingListAdapter = new EqpThingListAdapter(eqpEntity.getMATERIALINFO().getMATERIALINFO(), new DeleteCallback() {
                        @Override
                        public void onSuccess(MaterialInfoBean bean) {
                            final EntityCallBack<BaseEntity<FinishLotEntity>> callBack = new DialogEntityCallBack<BaseEntity<FinishLotEntity>>
                                    (new TypeToken<BaseEntity<FinishLotEntity>>() {
                                    }.getType(), getSupportFragmentManager(), this) {

                                @Override
                                public void onSuccess
                                        (final Response<BaseEntity<FinishLotEntity>> response) {
                                    if (response.body().isSuccess(StartFunction_SingulationActivity.this)) {
                                        requestData();
                                    } else {
                                        loadFail(response.body().getMessage());
                                    }
                                }

                                @Override
                                public void onError
                                        (Response<BaseEntity<FinishLotEntity>> response) {
                                    super.onError(response);
                                    loadError(response.getException(), "UnloadEQPMeterial");
                                }
                            };

                            Map<String, String> map = new HashMap<>();
                            map.put("EqpId", getEqpID());
                            map.put("MaterialPartNo", bean.getMaterialPartNo());
                            map.put("OPID", StaticMembers.CUR_USER.getUSERNAME());
                            map.put("Type", bean.getType());
                            map.put("SeqNo", bean.getSeqNo());
                            NetUtils.requestNet(this, "/UnloadEQPMeterial", map, callBack);
                        }
                    });
                    eqpThingListAdapter.openLoadAnimation(BaseQuickAdapter.ALPHAIN);
                    eqpThingListAdapter.setFragmentManager(getSupportFragmentManager());
                    eqpThingListAdapter.isFirstOnly(true);
                    rvEqpList.setAdapter(eqpThingListAdapter);
                    setData(eqpEntity.getLOTINFO());
                } else {
                  /*  loadFail(response.body().getMessage());
                    //mHandler.postDelayed(runnable, 1000);
                    StartFunction_SingulationActivity.this.finish();*/
                    showdailog(response.body().getMessage());
                }
            }

            @Override
            public void onError
                    (Response<BaseEntity<EqpEntity>> response) {
                super.onError(response);
                loadError(response.getException(), "ShowEQPInfoC2E");
                mHandler.postDelayed(runnable, 1000);
            }
        };

        Map<String, String> map = new HashMap<>();
        map.put("EQPID", getEqpID());
        NetUtils.requestNet(this, "/ShowEQPInfoC2E", map, callBack);
    }

    private void requestTest(final String method) {
        EntityCallBack<BaseEntity<FinishLotEntity>> callBack = new DialogEntityCallBack<BaseEntity<FinishLotEntity>>
                (new TypeToken<BaseEntity<FinishLotEntity>>() {
                }.getType(), getSupportFragmentManager(), this) {

            @Override
            public void onSuccess
                    (final Response<BaseEntity<FinishLotEntity>> response) {
                if (response.body().isSuccess(StartFunction_SingulationActivity.this)) {
                    Message message = new Message();
                    message.what = 0;
                    handler.sendMessage(message);
                    loadSuccess(response.body().getMessage());
                } else {
                    loadFail(response.body().getMessage());
                }
            }

            @Override
            public void onError
                    (Response<BaseEntity<FinishLotEntity>> response) {
                super.onError(response);
                loadError(response.getException(), method);
            }
        };

        Map<String, String> map = new HashMap<>();
        map.put("EQPID", getEqpID());
        map.put("USERNAME", StaticMembers.CUR_USER.getUSERNAME());
        map.put("REMAKE", etRemark.getText().toString().trim());
        map.put("LOTID", LotID);
        NetUtils.requestNet(this, "/" + method, map, callBack);
    }

    @OnClick({R.id.tvSubmitInputClassNum, R.id.btnBothChange, R.id.tvChoose, R.id.tvSubmitInput, R.id.rlMore, R.id.rlPic, R.id.rlInfo,
            R.id.tvSubmitRemark, R.id.btnChange, R.id.rlInput, R.id.btnStartKa, R.id.btnStartCut})
    public void onClick(View view) {
        if (AntiShake.check(view.getId())) {    //判断是否多次点击
            ToastUtils.showFreeToast("请勿重复点击",
                    StartFunction_SingulationActivity.this, false, Toast.LENGTH_SHORT);
            return;
        }
        switch (view.getId()) {
            case R.id.tvSubmitInputClassNum:
                if (lotInfo != null && lotInfo.getIsProcessStart()) {
                    String classNum = etClassNum.getText().toString().trim();
                    if (classNum.length() == 0) {
                        ToastUtils.showFreeToast("请输入班次产量",
                                StartFunction_SingulationActivity.this, false, Toast.LENGTH_SHORT);
                        return;
                    }
                    requestClassNum(getEqpID(), lotInfo.getLotId(), classNum, this, getSupportFragmentManager(), handler);
                } else {
                    ToastUtils.showFreeToast("没有LOT信息或者没有开始作业，不能提交班次产量",
                            StartFunction_SingulationActivity.this, false, Toast.LENGTH_SHORT);
                }
                break;
            case R.id.btnBothChange:
                Intent bothChangeIntent = new Intent(this, BothThingChangeActivity.class);
                bothChangeIntent.putExtra("mEntity1", materialInfoBeanList.get(0));
                bothChangeIntent.putExtra("mEntity2", materialInfoBeanList.get(1));
                bothChangeIntent.putExtra("eqpID", getEqpID());
                startActivity(bothChangeIntent);
                break;
            case R.id.tvChoose:
                if (generalPop == null) {
                    View mView = LayoutInflater.from(this).inflate(R.layout.popupwindow_down_list_select, null);
                    RecyclerView recyclerView = mView.findViewById(R.id.lvDownList);
                    recyclerView.setLayoutManager(new LinearLayoutManager(this));
                    recyclerView.setItemAnimator(new DefaultItemAnimator());
                    recyclerView.addItemDecoration(new DividerItemDecoration(this, 1));
                    List<String> list = new ArrayList<>();

                    for (InputDatasEntity.InputObjects inputObjects : inputList) {
                        list.add(inputObjects.getDATACNNAME());
                    }
                    generalPop = new GeneralPop(this, mView
                            , tvChoose.getWidth(), ViewGroup.LayoutParams.WRAP_CONTENT);
                    final PopDownAreaListAdapter popListAdapter = new PopDownAreaListAdapter(list);
                    popListAdapter.openLoadAnimation(BaseQuickAdapter.ALPHAIN);
                    popListAdapter.isFirstOnly(true);
                    popListAdapter.setOnItemClickListener(new BaseQuickAdapter.OnItemClickListener() {
                        @Override
                        public void onItemClick(BaseQuickAdapter adapter, View view, int position) {
                            if (rvInputList.getVisibility() == View.GONE) {
                                if (animation == null) {
                                    animation = new RotateAnimation(0f, 180f, Animation.RELATIVE_TO_SELF,
                                            0.5f, Animation.RELATIVE_TO_SELF, 0.5f);
                                    animation.setDuration(500);
                                    animation.setFillAfter(true);
                                }
                                ivDownArrow2.startAnimation(animation);
                                rvInputList.setVisibility(View.VISIBLE);
                            }
                            currentInputObject = inputList.get(position);
                            refreshInputAdapter();
                            popListAdapter.setCurrentSelect(position);
                            popListAdapter.notifyDataSetChanged();
                            tvChoose.setText(String.valueOf(adapter.getItem(position)));
                            generalPop.dismiss();
                        }
                    });
                    recyclerView.setAdapter(popListAdapter);
                    generalPop.setOutsideTouchable(true);
                }
                generalPop.showAsDropDown(tvChoose, 0, 0);
                break;
            case R.id.tvSubmitInput:
                if (tvChoose.getText().toString().equals("请选择")) {
                    ToastUtils.showFreeToast("请选择提交项", StartFunction_SingulationActivity.this, false, Toast.LENGTH_SHORT);
                    return;
                }
                boolean isInputOk = true;
                if (inputDataListAdapter != null) {
                    submitInputList = inputDataListAdapter.getData();
                    for (InputDataEntity.InputObject inputObject : submitInputList) {
                        inputObject.setEQPID(getEqpID());
                        if (inputObject.getISNULL().equalsIgnoreCase("Y") &&
                                inputObject.getDATAVALUE().length() == 0) {
                            ToastUtils.showFreeToast("请填写带*栏数据", StartFunction_SingulationActivity.this, false, Toast.LENGTH_SHORT);
                            isInputOk = false;
                        } else {
                            if (inputObject.getDATAVALUE().toUpperCase().contains("NG")) {
                                String[] strs = inputObject.getDATAVALUE().split(";");
                                if (strs.length <= 1) {
                                    isInputOk = false;
                                    ToastUtils.showFreeToast("请给NG项填写原因", StartFunction_SingulationActivity.this, false, Toast.LENGTH_SHORT);
                                }
                            }
                        }
                        if (!isInputOk) {
                            break;
                        }
                    }
                }
                if (isInputOk) {
                    requestInputData();
                }
                break;
            case R.id.btnStartKa:
                if (LotID.length() == 0) {
                    ToastUtils.showFreeToast("请先扫描LotID", StartFunction_SingulationActivity.this, false, Toast.LENGTH_SHORT);
                } else {
                    if (lotInfo == null) {
                        ToastUtils.showFreeToast("获取Lot信息失败", StartFunction_SingulationActivity.this, false, Toast.LENGTH_SHORT);
                    } else {
                        boolean isOk = true;
                        if (inputDataListAdapter != null) {
                            submitInputList = inputDataListAdapter.getData();
                            for (InputDataEntity.InputObject inputObject : submitInputList) {
                                if (inputObject.getISNULL().equalsIgnoreCase("Y") &&
                                        inputObject.getDATAVALUE().length() == 0) {
                                    ToastUtils.showFreeToast("请填写带*栏数据", StartFunction_SingulationActivity.this, false, Toast.LENGTH_SHORT);
                                    isOk = false;
                                } else {
                                    if (inputObject.getDATAVALUE().toUpperCase().contains("NG")) {
                                        String[] strs = inputObject.getDATAVALUE().split(";");
                                        if (strs.length <= 1) {
                                            isOk = false;
                                            ToastUtils.showFreeToast("请给NG项填写原因", StartFunction_SingulationActivity.this, false, Toast.LENGTH_SHORT);
                                        }
                                    }
                                }
                                if (!isOk) {
                                    break;
                                }
                            }
                        }
                        if (isOk) {
                            requestStartWork();
                        }
                    }
                }
                break;
            //add by bunny
            case R.id.btnStartCut:
                if (LotID.length() == 0) {
                    ToastUtils.showFreeToast("请先扫描LotID", StartFunction_SingulationActivity.this, false, Toast.LENGTH_SHORT);
                } else {
                    if (lotInfo == null) {
                        ToastUtils.showFreeToast("获取Lot信息失败", StartFunction_SingulationActivity.this, false, Toast.LENGTH_SHORT);
                    } else {
                        boolean isOk = true;
                        if (inputDataListAdapter != null) {
                            submitInputList = inputDataListAdapter.getData();
                            for (InputDataEntity.InputObject inputObject : submitInputList) {
                                if (inputObject.getISNULL().equalsIgnoreCase("Y") &&
                                        inputObject.getDATAVALUE().length() == 0) {
                                    ToastUtils.showFreeToast("请填写带*栏数据", StartFunction_SingulationActivity.this, false, Toast.LENGTH_SHORT);
                                    isOk = false;
                                } else {
                                    if (inputObject.getDATAVALUE().toUpperCase().contains("NG")) {
                                        String[] strs = inputObject.getDATAVALUE().split(";");
                                        if (strs.length <= 1) {
                                            isOk = false;
                                            ToastUtils.showFreeToast("请给NG项填写原因", StartFunction_SingulationActivity.this, false, Toast.LENGTH_SHORT);
                                        }
                                    }
                                }
                                if (!isOk) {
                                    break;
                                }
                            }
                        }
                        if (isOk) {
                            requestStartCutEdge();
                        }
                    }
                }
                break;
            //end
            case R.id.rlInput:
                if (rvInputList.getVisibility() == View.VISIBLE) {
                    if (animationDismiss == null) {
                        animationDismiss = new RotateAnimation(180f, 0f, Animation.RELATIVE_TO_SELF,
                                0.5f, Animation.RELATIVE_TO_SELF, 0.5f);
                        animationDismiss.setDuration(500);
                        animationDismiss.setFillAfter(true);
                    }
                    ivDownArrow2.startAnimation(animationDismiss);
                    rvInputList.setVisibility(View.GONE);
                } else {
                    if (animation == null) {
                        animation = new RotateAnimation(0f, 180f, Animation.RELATIVE_TO_SELF,
                                0.5f, Animation.RELATIVE_TO_SELF, 0.5f);
                        animation.setDuration(500);
                        animation.setFillAfter(true);
                    }
                    ivDownArrow2.startAnimation(animation);
                    rvInputList.setVisibility(View.VISIBLE);
                }
                break;
            case R.id.rlInfo:
                if (rvThingList.getVisibility() == View.VISIBLE) {
                    if (animationDismiss == null) {
                        animationDismiss = new RotateAnimation(180f, 0f, Animation.RELATIVE_TO_SELF,
                                0.5f, Animation.RELATIVE_TO_SELF, 0.5f);
                        animationDismiss.setDuration(500);
                        animationDismiss.setFillAfter(true);
                    }
                    ivDownArrow.startAnimation(animationDismiss);
                    rvThingList.setVisibility(View.GONE);
                } else {
                    if (animation == null) {
                        animation = new RotateAnimation(0f, 180f, Animation.RELATIVE_TO_SELF,
                                0.5f, Animation.RELATIVE_TO_SELF, 0.5f);
                        animation.setDuration(500);
                        animation.setFillAfter(true);
                    }
                    ivDownArrow.startAnimation(animation);
                    rvThingList.setVisibility(View.VISIBLE);
                }
                break;
            case R.id.rlMore:
                Intent allMessageIntent = new Intent(StartFunction_SingulationActivity.this, AllMessageActivity.class);
                allMessageIntent.putExtra("eqpID", getEqpID());
                startActivity(allMessageIntent);
                break;
            case R.id.rlPic:
                Intent intent = new Intent(StartFunction_SingulationActivity.this, PicViewActivity.class);
                intent.putExtra("pic", pic);
                intent.putExtra("picVersion", picVersion);
                startActivity(intent);
                break;
            case R.id.tvSubmitRemark:
                if (etRemark.getText().toString().trim().length() > 0) {
                    StartFunctionActivity.requestSubmitRemark(getEqpID(), LotID, etRemark.getText().toString(), StartFunction_SingulationActivity.this, getSupportFragmentManager());
                } else {
                    ToastUtils.showFreeToast("请填写备注后再提交",
                            StartFunction_SingulationActivity.this, false, Toast.LENGTH_SHORT);
                }
                break;
            case R.id.btnChange:
                Intent changeCardIntent = new Intent(StartFunction_SingulationActivity.this, ChangeCardActivity.class);
                changeCardIntent.putExtra("eqpID", getEqpID());
                changeCardIntent.putExtra("LotId", LotID);//add by bunny
                startActivity(changeCardIntent);
                break;
        }
    }

    private void refreshInputAdapter() {
        inputDataListAdapter = new InputDataListAdapter(currentInputObject.getINPUTDATAS().getINPUTDATA());
        inputDataListAdapter.openLoadAnimation(BaseQuickAdapter.ALPHAIN);
        inputDataListAdapter.isFirstOnly(true);
        rvInputList.setAdapter(inputDataListAdapter);
    }

    private void requestInputData() {
        EntityCallBack<BaseEntity<FinishLotEntity>> callBack = new DialogEntityCallBack<BaseEntity<FinishLotEntity>>
                (new TypeToken<BaseEntity<FinishLotEntity>>() {
                }.getType(), getSupportFragmentManager(), this) {

            @Override
            public void onSuccess
                    (final Response<BaseEntity<FinishLotEntity>> response) {
                if (response.body().isSuccess(StartFunction_SingulationActivity.this)) {
                    refreshPop();
                    requestData();
                    loadSuccess(response.body().getMessage());
                } else {
                    loadFail(response.body().getMessage());
                }
            }

            @Override
            public void onError
                    (Response<BaseEntity<FinishLotEntity>> response) {
                super.onError(response);
                loadError(response.getException(), "SubmitInputData");
            }
        };

        Map<String, String> map = new HashMap<>();
        JSONObject jsonObject = new JSONObject();
        try {
            JSONObject jsonObject2 = new JSONObject();
            jsonObject2.put("DATACNNAME", currentInputObject.getDATACNNAME());
            jsonObject2.put("DATANAME", currentInputObject.getDATANAME());
            if (submitInputList.size() == 0) {
                jsonObject2.put("INPUTDATAS", new JSONObject().put("INPUTDATA", ""));
            } else {
                JSONArray jsonArray = new JSONArray(new Gson().toJson(submitInputList));
                jsonObject2.put("INPUTDATAS", new JSONObject().put("INPUTDATA", jsonArray));
            }
            jsonObject.put("INPUTDATA", jsonObject2);
        } catch (JSONException e) {
            e.printStackTrace();
        }
        map.put("InputDataList", jsonObject.toString());
        map.put("OPID", StaticMembers.CUR_USER.getUSERNAME());
        map.put("EqpId", getEqpID());
        map.put("InputDataType", "LOT");
        NetUtils.requestNet(this, "/SubmitInputData", map, callBack);
    }

    private void requestStartCutEdge() {
        EntityCallBack<BaseEntity<FinishLotEntity>> callBack = new DialogEntityCallBack<BaseEntity<FinishLotEntity>>
                (new TypeToken<BaseEntity<FinishLotEntity>>() {
                }.getType(), getSupportFragmentManager(), this) {

            @Override
            public void onSuccess
                    (final Response<BaseEntity<FinishLotEntity>> response) {
                if (response.body().isSuccess(StartFunction_SingulationActivity.this)) {
                    Message message = new Message();
                    message.what = 0;
                    handler.sendMessage(message);
                    loadSuccess(response.body().getMessage());
                } else {
                    loadFail(response.body().getMessage());
                }
            }

            @Override
            public void onError
                    (Response<BaseEntity<FinishLotEntity>> response) {
                super.onError(response);
                loadError(response.getException(), "StartCutEdge");
            }
        };

        Map<String, String> map = new HashMap<>();
        map.put("EqpId", getEqpID());
        map.put("LotId", LotID);
        map.put("USERNAME", StaticMembers.CUR_USER.getUSERNAME());
        map.put("Remark", etRemark.getText().toString().trim());
        map.put("TotalQty", etNum.getText().toString().trim().length() == 0 ? "0" : etNum.getText().toString().trim());
        JSONObject jsonObject = new JSONObject();
        try {
            JSONObject jsonObject2 = new JSONObject();
            jsonObject2.put("DATACNNAME", currentInputObject.getDATACNNAME());
            jsonObject2.put("DATANAME", currentInputObject.getDATANAME());
            if (submitInputList.size() == 0) {
                jsonObject2.put("INPUTDATAS", new JSONObject().put("INPUTDATA", ""));
            } else {
                JSONArray jsonArray = new JSONArray(new Gson().toJson(submitInputList));
                jsonObject2.put("INPUTDATAS", new JSONObject().put("INPUTDATA", jsonArray));
            }
            jsonObject.put("INPUTDATA", jsonObject2);
        } catch (JSONException e) {
            e.printStackTrace();
        }
        map.put("InputDataList", jsonObject.toString());
        map.put("StartMode", startMode);
        NetUtils.requestNet(this, "/StartCutEdge", map, callBack);
    }

    private void requestStartWork() {
        String bladeStr = etBladeExp.getText().toString().trim();
        if (llBladeExp.getVisibility() == View.VISIBLE && StringUtils.isEmpty(bladeStr)) {
            ToastUtils.showFreeToast("请填写刀片暴露量", StartFunction_SingulationActivity.this, false, Toast.LENGTH_SHORT);
            return;
        }
        EntityCallBack<BaseEntity<FinishLotEntity>> callBack = new DialogEntityCallBack<BaseEntity<FinishLotEntity>>
                (new TypeToken<BaseEntity<FinishLotEntity>>() {
                }.getType(), getSupportFragmentManager(), this) {

            @Override
            public void onSuccess
                    (final Response<BaseEntity<FinishLotEntity>> response) {
                if (response.body().isSuccess(StartFunction_SingulationActivity.this)) {
                    Message message = new Message();
                    message.what = 0;
                    handler.sendMessage(message);
                    loadSuccess(response.body().getMessage());
                } else {
                    loadFail(response.body().getMessage());
                }
            }

            @Override
            public void onError
                    (Response<BaseEntity<FinishLotEntity>> response) {
                super.onError(response);
                loadError(response.getException(), "StartProcess");
            }
        };

        Map<String, String> map = new HashMap<>();
        map.put("EqpId", getEqpID());
        map.put("LotId", LotID);
        map.put("USERNAME", StaticMembers.CUR_USER.getUSERNAME());
        map.put("Remark", etRemark.getText().toString().trim());
        map.put("TotalQty", etNum.getText().toString().trim().length() == 0 ? "0" : etNum.getText().toString().trim());
        JSONObject jsonObject = new JSONObject();
        try {
            JSONObject jsonObject2 = new JSONObject();
            jsonObject2.put("DATACNNAME", currentInputObject.getDATACNNAME());
            jsonObject2.put("DATANAME", currentInputObject.getDATANAME());
            if (submitInputList.size() == 0) {
                jsonObject2.put("INPUTDATAS", new JSONObject().put("INPUTDATA", ""));
            } else {
                JSONArray jsonArray = new JSONArray(new Gson().toJson(submitInputList));
                jsonObject2.put("INPUTDATAS", new JSONObject().put("INPUTDATA", jsonArray));
            }
            jsonObject.put("INPUTDATA", jsonObject2);
        } catch (JSONException e) {
            e.printStackTrace();
        }
        map.put("InputDataList", jsonObject.toString());
        map.put("StartMode", startMode);
        map.put("BladeExp", bladeStr);
        NetUtils.requestNet(this, "/StartProcess", map, callBack);
    }

    private void refreshPop() {
        generalPop = null;
        tvChoose.setText("请选择");
        rvInputList.setVisibility(View.GONE);
    }

    @Override
    protected int getLayoutResId() {
        return R.layout.activity_singulation_start_function;
    }

    @Override
    protected void initView() {
        //  topView.setTitle("批次开始(" + StaticMembers.CUR_USER.getUSERNAME() + ")");
        topView.setTitle("批次开始(" + StaticMembers.CUR_USER.getUSERNAME() + ")\n模式未更新");
        topView.setTitleMode(TitleView.NORMAL_TEXT_MODE);
        topView.setLeftListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                final DeleteFragmentDialog deleteFragmentDialog = new DeleteFragmentDialog();
                deleteFragmentDialog.setData("确定返回主界面吗？", new View.OnClickListener() {
                    @Override
                    public void onClick(View v) {
                        if (AntiShake.check(v.getId())) {    //判断是否多次点击
                            ToastUtils.showFreeToast("请勿重复点击",
                                    StartFunction_SingulationActivity.this, false, Toast.LENGTH_SHORT);
                            return;
                        }
                        deleteFragmentDialog.dismiss();
                        unbindLot();
                    }
                });
                deleteFragmentDialog.show(getSupportFragmentManager(), "unbind_dialog");
            }
        });
        rvInputList.setLayoutManager(new LinearLayoutManager(StartFunction_SingulationActivity.this));
        rvInputList.setItemAnimator(new DefaultItemAnimator());
        rvInputList.addItemDecoration(new DividerItemDecoration(StartFunction_SingulationActivity.this, 1));

        rvThingList.setLayoutManager(new LinearLayoutManager(StartFunction_SingulationActivity.this));
        rvThingList.setItemAnimator(new DefaultItemAnimator());
        rvThingList.addItemDecoration(new DividerItemDecoration(StartFunction_SingulationActivity.this, 1));

        rvEqpList.setLayoutManager(new LinearLayoutManager(StartFunction_SingulationActivity.this));
        rvEqpList.setItemAnimator(new DefaultItemAnimator());
        rvEqpList.addItemDecoration(new DividerItemDecoration(StartFunction_SingulationActivity.this, 1));

        rvMessageList.setLayoutManager(new LinearLayoutManager(StartFunction_SingulationActivity.this));
        rvMessageList.setItemAnimator(new DefaultItemAnimator());
        rvMessageList.addItemDecoration(new DividerItemDecoration(StartFunction_SingulationActivity.this, 1));
        etLotItem.setOnEditorActionListener(new TextView.OnEditorActionListener() {
            @Override
            public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
                return event != null && (event.getKeyCode() == KeyEvent.KEYCODE_ENTER);
            }
        });
        etLotItem.addTextChangedListener(new TextWatcher() {
            @Override
            public void beforeTextChanged(CharSequence s, int start, int count, int after) {

            }

            @Override
            public void onTextChanged(CharSequence s, int start, int before, int count) {
                if (start == 0 && before == 0 && count > 1) {
                    if (s.length() > 0) {
                        LotID = s.toString();
                        requestLotInfo();
                    } else {
                        ToastUtils.showFreeToast("扫描信息有误", StartFunction_SingulationActivity.this, false, Toast.LENGTH_SHORT);
                    }
                }
            }

            @Override
            public void afterTextChanged(Editable s) {

            }
        });

        toggleButton.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
            @Override
            public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
                if (isChecked) {
                    startMode = "M";
                } else {
                    startMode = "A";
                }
            }
        });
    }

    @Override
    protected void initData() {
        etLotItem.postDelayed(new Runnable() {
            @Override
            public void run() {
                etLotItem.requestFocus();
            }
        }, 500);
        setCallback(etLotItem);
        messageEntityList = new ArrayList<>();
        messageListAdapter = new MessageListAdapter(messageEntityList);
        messageListAdapter.openLoadAnimation(BaseQuickAdapter.ALPHAIN);
        messageListAdapter.isFirstOnly(true);
        rvMessageList.setAdapter(messageListAdapter);
    }

    @Override
    protected void onDestroy() {
        super.onDestroy();
        StaticMembers.isOffLine = false;
        OkGo.getInstance().cancelTag(this);
        if (timer != null) {
            timer.cancel();
        }
        mHandler.removeCallbacks(runnable);
    }

    @Override
    public boolean onKeyDown(int keyCode, KeyEvent event) {
        if (keyCode == KeyEvent.KEYCODE_BACK) {
            boolean isAll = true;
            for (WarnPop warnPop : dialogList) {
                if (warnPop.isShowing()) {
                    isAll = false;
                    break;
                }
            }
            if (isAll) {
                final DeleteFragmentDialog deleteFragmentDialog = new DeleteFragmentDialog();
                deleteFragmentDialog.setData("确定返回主界面吗？", new View.OnClickListener() {
                    @Override
                    public void onClick(View v) {
                        if (AntiShake.check(v.getId())) {    //判断是否多次点击
                            ToastUtils.showFreeToast("请勿重复点击",
                                    StartFunction_SingulationActivity.this, false, Toast.LENGTH_SHORT);
                            return;
                        }
                        deleteFragmentDialog.dismiss();
                        unbindLot();
                    }
                });
                deleteFragmentDialog.show(getSupportFragmentManager(), "unbind_dialog");
            }
            return true;
        }
        return super.onKeyDown(keyCode, event);
    }

    @Override
    protected void onPause() {
        super.onPause();
        if (timer != null) {
            timer.cancel();
        }
    }

    @Override
    protected void onResume() {
        super.onResume();
        requestData();
    }

    private void unbindLot() {
        if (lotInfo != null) {
            if (lotInfo.getIsProcessStart()) {
                StartFunction_SingulationActivity.this.finish();
            } else {
                requestUnbind();
            }
        } else {
            StartFunction_SingulationActivity.this.finish();
        }
    }

    private void requestLotInfo() {
        EntityCallBack<BaseEntity<LotInfoEntity>> callBack = new DialogEntityCallBack<BaseEntity<LotInfoEntity>>
                (new TypeToken<BaseEntity<LotInfoEntity>>() {
                }.getType(), getSupportFragmentManager(), this) {

            @Override
            public void onSuccess
                    (final Response<BaseEntity<LotInfoEntity>> response) {

                if (response.body().isSuccess(StartFunction_SingulationActivity.this)) {
                    if (response.body().isNotNull()) {
                        setData(response.body().getData());
                        requestPicData(response.body().getData());
                    } else {
                        loadFail("扫描的LOT信息不存在");
                    }
                } else {
                    loadFail(response.body().getMessage());
                }
            }

            @Override
            public void onError
                    (Response<BaseEntity<LotInfoEntity>> response) {
                super.onError(response);
                loadError(response.getException(), "LotIn");
            }
        };

        Map<String, String> map = new HashMap<>();
        map.put("EQPID", getEqpID());
        map.put("LOTID", LotID);
        map.put("USERNAME", StaticMembers.CUR_USER.getUSERNAME());
        NetUtils.requestNet(this, "/LotIn", map, callBack);
    }

    private void requestUnbind() {
        EntityCallBack<BaseEntity<FinishLotEntity>> callBack = new DialogEntityCallBack<BaseEntity<FinishLotEntity>>
                (new TypeToken<BaseEntity<FinishLotEntity>>() {
                }.getType(), getSupportFragmentManager(), this) {

            @Override
            public void onSuccess
                    (final Response<BaseEntity<FinishLotEntity>> response) {
                if (response.body().isSuccess(StartFunction_SingulationActivity.this)) {
                    mHandler.postDelayed(runnable, 1000);
                    loadSuccess(response.body().getMessage());
                } else {
                    loadFail(response.body().getMessage());
                }
            }

            @Override
            public void onError
                    (Response<BaseEntity<FinishLotEntity>> response) {
                super.onError(response);
                loadError(response.getException(), "RemoveEQPLot");
            }
        };

        Map<String, String> map = new HashMap<>();
        map.put("EQPID", getEqpID());
        map.put("USERNAME", StaticMembers.CUR_USER.getUSERNAME());
        NetUtils.requestNet(this, "/RemoveEQPLot", map, callBack);
    }

    private void setData(LotInfoEntity lotInfoEntity) {
        lotInfo = lotInfoEntity;
        if (lotInfoEntity == null) {
            etLotItem.setEnabled(true);
            llCard.setVisibility(View.GONE);
            topView.setRightListener("", new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                }
            });
            lotInfoEntity = new LotInfoEntity();
        } else {
            llCard.setVisibility(View.VISIBLE);
            tvBlock.setText(lotInfoEntity.getBlock());
            tvPianNo.setText(lotInfoEntity.getPIECENO());
            if (lotInfoEntity.getIsProcessStart()) {
                etLotItem.setEnabled(false);
                topView.setRightListener("结束作业", new View.OnClickListener() {
                    @Override
                    public void onClick(View v) {
                        if (AntiShake.check(v.getId())) {    //判断是否多次点击
                            ToastUtils.showFreeToast("请勿重复点击",
                                    StartFunction_SingulationActivity.this, false, Toast.LENGTH_SHORT);
                            return;
                        }
                        Intent intent = new Intent(StartFunction_SingulationActivity.this, EndFunctionActivity.class);
                        intent.putExtra("eqpID", getEqpID());
                        intent.putExtra("eqpType",eqpType);
                        startActivityForResult(intent, 1);
                    }
                });
            } else {
                topView.setRightListener("", new View.OnClickListener() {
                    @Override
                    public void onClick(View v) {
                    }
                });
            }
        }
        LotID = lotInfoEntity.getLotId();

        thingListAdapter = new ThingListAdapter(lotInfoEntity.getMaterials().getMesMaterial());
        thingListAdapter.openLoadAnimation(BaseQuickAdapter.ALPHAIN);
        thingListAdapter.isFirstOnly(true);
        rvThingList.setAdapter(thingListAdapter);

        pic = lotInfoEntity.getDiagram();
        picVersion = lotInfoEntity.getDiagramVersion();
        rlPic.setVisibility(pic.length() > 0 && picVersion.length() > 0 ? View.VISIBLE : View.GONE);

        tvLogId.setText(lotInfoEntity.getLotId());
//        tvDevice.setText(lotInfoEntity.getDevice());
//        tvWafer.setText(lotInfoEntity.getWaferSource());
        tvEdgeRecipeId.setText(lotInfoEntity.getEdgeRecipeId());  //add by bunny
        tvEdgeRecipeNo.setText(lotInfoEntity.getEdgeRecipeNo());  //add by bunny
        tvRecipeName.setText(lotInfoEntity.getRecipeId());
        tvRecipeNo.setText(lotInfoEntity.getRecipeNo());
        tvPic.setText(lotInfoEntity.getDiagram());
        tvPicVersion.setText(lotInfoEntity.getDiagramVersion());
        etNum.setText(lotInfoEntity.getTotalQty());
        tvPackage.setText(lotInfoEntity.getPackage());
        tvAlreadyDown.setText(lotInfoEntity.getShiftDoneQty());
        etClassNum.setText("");
    }

    private void requestPicData(final LotInfoEntity lotData) {
        if (pic.length() <= 0 || picVersion.length() <= 0) {
//            btnStartKa.setEnabled(false);
            //showPicPop(llMain, this, "当前LOT没有焊线图，不能开始作业");
            //showPicPop(llMain, this, "当前LOT没有焊线图");
        } else {
            EntityCallBack<BaseEntity<PicEntity>> callBack = new DialogEntityCallBack<BaseEntity<PicEntity>>
                    (new TypeToken<BaseEntity<PicEntity>>() {
                    }.getType(), getSupportFragmentManager(), this) {

                @Override
                public void onSuccess
                        (final Response<BaseEntity<PicEntity>> response) {
                    if (response.body().isSuccess(StartFunction_SingulationActivity.this)) {
                        btnStartKa.setEnabled(true);
                        if (getEqpID().toLowerCase().contains("fs")
                                && lotData.getDIESEQLIST().getDIESEQ().size() > 1) {
                            Intent intent = new Intent(StartFunction_SingulationActivity.this, ChooseDiePicViewActivity.class);
                            intent.putExtra("pic", pic);
                            intent.putExtra("picVersion", picVersion);
                            intent.putExtra("lotId", LotID);
                            intent.putExtra("eid", getEqpID());
                            intent.putExtra("dataList", lotData.getDIESEQLIST());
                            startActivity(intent);
                        }
                    } else {
//                        btnStartKa.setEnabled(false);
                        //showPicPop(llMain, StartFunction_SingulationActivity.this, "当前LOT没有焊线图，不能开始作业");
                        //showPicPop(llMain, StartFunction_SingulationActivity.this, "当前LOT没有焊线图");
                    }
                }

                @Override
                public void onError
                        (Response<BaseEntity<PicEntity>> response) {
                    super.onError(response);
                    btnStartKa.setEnabled(false);
                    showPicPop(llMain, StartFunction_SingulationActivity.this, "焊线图校检失败，请重新扫描lot");
                    loadError(response.getException(), "WeldingDrawing");
                }
            };

            Map<String, String> map = new HashMap<>();
            map.put("htmlfileName", pic);
            map.put("DiagramVersion", picVersion);
            NetUtils.requestNet(this, "/WeldingDrawing", map, callBack);
        }
    }
}
